/**
 * @param {number} x
 * @return {number}
 */
var reverse = function(x) {

  var string = (String)(x);

  var array = string.split("")

  var result = ''

  if(array[0]==='-'){

    array.shift()

    result = '-'+array.reverse().join('')


  }else{
     result = array.reverse().join('')
  }

  console.log(result)

};

var x = 123;
 reverse(x)